home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Hardware / PowerManager DDK 1.0f1 / Interfaces&Libraries / Interfaces / Devices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-08  |  27.7 KB  |  853 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Devices.h
  3.  
  4.      Contains:    Device Manager Interfaces.
  5.  
  6.      Version:    Mac OS 8
  7.  
  8.      DRI:        Nick Kledzik
  9.  
  10.      Copyright:    © 1985-1999 by Apple Computer, Inc., all rights reserved
  11.  
  12.      Warning:    *** APPLE INTERNAL USE ONLY ***
  13.                  This file may contain unreleased API's
  14.  
  15.      BuildInfo:    Built by:            Scott Johnson
  16.                  On:                    10/8/99 11:26 AM
  17.                  With Interfacer:    3.0d13   (MPW PowerPC)
  18.                  From:                Devices.i
  19.                      Revision:        103
  20.                      Dated:            5/8/99
  21.                      Last change by:    SAJ
  22.                      Last comment:    Oops, that should've been kPowerManagementCommand down below.
  23.  
  24.      Bugs:        Report bugs to Radar component "System Interfaces", "Latest"
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __DEVICES__
  29. #define __DEVICES__
  30.  
  31. #ifndef __OSUTILS__
  32. #include <OSUtils.h>
  33. #endif
  34.  
  35. #ifndef __FILES__
  36. #include <Files.h>
  37. #endif
  38.  
  39. #ifndef __QUICKDRAW__
  40. #include <Quickdraw.h>
  41. #endif
  42.  
  43. #ifndef __NAMEREGISTRY__
  44. #include <NameRegistry.h>
  45. #endif
  46.  
  47. #ifndef __CODEFRAGMENTS__
  48. #include <CodeFragments.h>
  49. #endif
  50.  
  51. #ifndef __DRIVERFAMILYMATCHING__
  52. #include <DriverFamilyMatching.h>
  53. #endif
  54.  
  55.  
  56.  
  57.  
  58. #if PRAGMA_ONCE
  59. #pragma once
  60. #endif
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif
  65.  
  66. #if PRAGMA_IMPORT
  67. #pragma import on
  68. #endif
  69.  
  70. #if PRAGMA_STRUCT_ALIGN
  71.     #pragma options align=mac68k
  72. #elif PRAGMA_STRUCT_PACKPUSH
  73.     #pragma pack(push, 2)
  74. #elif PRAGMA_STRUCT_PACK
  75.     #pragma pack(2)
  76. #endif
  77.  
  78. /* Values of the 'message' parameter to a Chooser device package */
  79. enum {
  80.     chooserInitMsg                = 11,                            /* the user selected this device package */
  81.     newSelMsg                    = 12,                            /* the user made new device selections */
  82.     fillListMsg                    = 13,                            /* fill the device list with choices */
  83.     getSelMsg                    = 14,                            /* mark one or more choices as selected */
  84.     selectMsg                    = 15,                            /* the user made a selection */
  85.     deselectMsg                    = 16,                            /* the user canceled a selection */
  86.     terminateMsg                = 17,                            /* allows device package to clean up */
  87.     buttonMsg                    = 19                            /* the user selected a button */
  88. };
  89.  
  90.  
  91. /* Values of the 'caller' parameter to a Chooser device package */
  92. enum {
  93.     chooserID                    = 1
  94. };
  95.  
  96.  
  97. /* Values of the 'message' parameter to a Monitor 'mntr' */
  98. enum {
  99.     initMsg                        = 1,                            /*initialization*/
  100.     okMsg                        = 2,                            /*user clicked OK button*/
  101.     cancelMsg                    = 3,                            /*user clicked Cancel button*/
  102.     hitMsg                        = 4,                            /*user clicked control in Options dialog*/
  103.     nulMsg                        = 5,                            /*periodic event*/
  104.     updateMsg                    = 6,                            /*update event*/
  105.     activateMsg                    = 7,                            /*not used*/
  106.     deactivateMsg                = 8,                            /*not used*/
  107.     keyEvtMsg                    = 9,                            /*keyboard event*/
  108.     superMsg                    = 10,                            /*show superuser controls*/
  109.     normalMsg                    = 11,                            /*show only normal controls*/
  110.     startupMsg                    = 12                            /*code has been loaded*/
  111. };
  112.  
  113.  
  114. /* control codes for DeskAccessories */
  115. enum {
  116.     goodbye                        = -1,                            /* heap being reinitialized */
  117.     killCode                    = 1,                            /* KillIO requested */
  118.     accEvent                    = 64,                            /* handle an event */
  119.     accRun                        = 65,                            /* time for periodic action */
  120.     accCursor                    = 66,                            /* change cursor shape */
  121.     accMenu                        = 67,                            /* handle menu item */
  122.     accUndo                        = 68,                            /* handle undo command */
  123.     accCut                        = 70,                            /* handle cut command */
  124.     accCopy                        = 71,                            /* handle copy command */
  125.     accPaste                    = 72,                            /* handle paste command */
  126.     accClear                    = 73                            /* handle clear command */
  127. };
  128.  
  129. /* Control/Status Call Codes */
  130. enum {
  131.     drvStsCode                    = 8,                            /* status call code for drive status */
  132.     ejectCode                    = 7,                            /* control call eject code */
  133.     tgBuffCode                    = 8                                /* set tag buffer code */
  134. };
  135.  
  136. /* miscellaneous Device Manager constants */
  137. enum {
  138.     ioInProgress                = 1,                            /* predefined value of ioResult while I/O is pending */
  139.     aRdCmd                        = 2,                            /* low byte of ioTrap for Read calls */
  140.     aWrCmd                        = 3,                            /* low byte of ioTrap for Write calls */
  141.     asyncTrpBit                    = 10,                            /* trap word modifier */
  142.     noQueueBit                    = 9                                /* trap word modifier */
  143. };
  144.  
  145. /* flags used in the driver header and device control entry */
  146. enum {
  147.     dReadEnable                    = 0,                            /* set if driver responds to read requests */
  148.     dWritEnable                    = 1,                            /* set if driver responds to write requests */
  149.     dCtlEnable                    = 2,                            /* set if driver responds to control requests */
  150.     dStatEnable                    = 3,                            /* set if driver responds to status requests */
  151.     dNeedGoodBye                = 4,                            /* set if driver needs time for performing periodic tasks */
  152.     dNeedTime                    = 5,                            /* set if driver needs time for performing periodic tasks */
  153.     dNeedLock                    = 6                                /* set if driver must be locked in memory as soon as it is opened */
  154. };
  155.  
  156. enum {
  157.     dNeedLockMask                = 0x4000,                        /* set if driver must be locked in memory as soon as it is opened */
  158.     dNeedTimeMask                = 0x2000,                        /* set if driver needs time for performing periodic tasks */
  159.     dNeedGoodByeMask            = 0x1000,                        /* set if driver needs to be called before the application heap is initialized */
  160.     dStatEnableMask                = 0x0800,                        /* set if driver responds to status requests */
  161.     dCtlEnableMask                = 0x0400,                        /* set if driver responds to control requests */
  162.     dWritEnableMask                = 0x0200,                        /* set if driver responds to write requests */
  163.     dReadEnableMask                = 0x0100                        /* set if driver responds to read requests */
  164. };
  165.  
  166.  
  167. /* run-time flags used in the device control entry */
  168. enum {
  169.     dOpened                        = 5,                            /* driver is open */
  170.     dRAMBased                    = 6,                            /* dCtlDriver is a handle (1) or pointer (0) */
  171.     drvrActive                    = 7                                /* driver is currently processing a request */
  172. };
  173.  
  174. enum {
  175.     drvrActiveMask                = 0x0080,                        /* driver is currently processing a request */
  176.     dRAMBasedMask                = 0x0040,                        /* dCtlDriver is a handle (1) or pointer (0) */
  177.     dOpenedMask                    = 0x0020                        /* driver is open */
  178. };
  179.  
  180.  
  181.  
  182. struct DRVRHeader {
  183.     short                             drvrFlags;
  184.     short                             drvrDelay;
  185.     short                             drvrEMask;
  186.     short                             drvrMenu;
  187.     short                             drvrOpen;
  188.     short                             drvrPrime;
  189.     short                             drvrCtl;
  190.     short                             drvrStatus;
  191.     short                             drvrClose;
  192.     unsigned char                     drvrName[1];
  193. };
  194. typedef struct DRVRHeader                DRVRHeader;
  195. typedef DRVRHeader *                    DRVRHeaderPtr;
  196. typedef DRVRHeaderPtr *                    DRVRHeaderHandle;
  197.  
  198. struct DCtlEntry {
  199.     Ptr                             dCtlDriver;
  200.     volatile short                     dCtlFlags;
  201.     QHdr                             dCtlQHdr;
  202.     volatile long                     dCtlPosition;
  203.     Handle                             dCtlStorage;
  204.     short                             dCtlRefNum;
  205.     long                             dCtlCurTicks;
  206.     GrafPtr                         dCtlWindow;
  207.     short                             dCtlDelay;
  208.     short                             dCtlEMask;
  209.     short                             dCtlMenu;
  210. };
  211. typedef struct DCtlEntry                DCtlEntry;
  212.  
  213. typedef DCtlEntry *                        DCtlPtr;
  214. typedef DCtlPtr *                        DCtlHandle;
  215.  
  216. struct AuxDCE {
  217.     Ptr                             dCtlDriver;
  218.     volatile short                     dCtlFlags;
  219.     QHdr                             dCtlQHdr;
  220.     long                             dCtlPosition;
  221.     Handle                             dCtlStorage;
  222.     short                             dCtlRefNum;
  223.     long                             dCtlCurTicks;
  224.     GrafPtr                         dCtlWindow;
  225.     short                             dCtlDelay;
  226.     short                             dCtlEMask;
  227.     short                             dCtlMenu;
  228.     SInt8                             dCtlSlot;
  229.     SInt8                             dCtlSlotId;
  230.     long                             dCtlDevBase;
  231.     Ptr                             dCtlOwner;
  232.     SInt8                             dCtlExtDev;
  233.     SInt8                             fillByte;
  234.     UInt32                             dCtlNodeID;
  235. };
  236. typedef struct AuxDCE                    AuxDCE;
  237. typedef AuxDCE *                        AuxDCEPtr;
  238. typedef AuxDCEPtr *                        AuxDCEHandle;
  239. /*    The NDRV Driver IO Entry Point and Commands */
  240.  
  241. typedef UInt16                             UnitNumber;
  242. typedef UInt32                             DriverOpenCount;
  243. typedef SInt16                             DriverRefNum;
  244. typedef SInt16                             DriverFlags;
  245. typedef UInt32                             IOCommandCode;
  246. enum {
  247.     kOpenCommand                = 0,
  248.     kCloseCommand                = 1,
  249.     kReadCommand                = 2,
  250.     kWriteCommand                = 3,
  251.     kControlCommand                = 4,
  252.     kStatusCommand                = 5,
  253.     kKillIOCommand                = 6,
  254.     kInitializeCommand            = 7,                            /* init driver and device*/
  255.     kFinalizeCommand            = 8,                            /* shutdown driver and device*/
  256.     kReplaceCommand                = 9,                            /* replace an old driver*/
  257.     kSupersededCommand            = 10,                            /* prepare to be replaced by a new driver*/
  258.     kSuspendCommand                = 11,                            /* prepare driver to go to sleep*/
  259.     kResumeCommand                = 12                            /* wake up sleeping driver*/
  260. };
  261.  
  262. enum {
  263.                                                                 /* one more IOCommandCode*/
  264.     kPowerManagementCommand        = 13                            /* power management command, supercedes kSuspendCommand and kResumeCommand*/
  265. };
  266.  
  267. typedef struct OpaqueAddressSpaceID*     AddressSpaceID;
  268. typedef struct OpaqueIOCommandID*         IOCommandID;
  269. typedef UInt32                             IOCommandKind;
  270. enum {
  271.     kSynchronousIOCommandKind    = 0x00000001,
  272.     kAsynchronousIOCommandKind    = 0x00000002,
  273.     kImmediateIOCommandKind        = 0x00000004
  274. };
  275.  
  276.  
  277. struct DriverInitInfo {
  278.     DriverRefNum                     refNum;
  279.     RegEntryID                         deviceEntry;
  280. };
  281. typedef struct DriverInitInfo            DriverInitInfo;
  282. typedef DriverInitInfo *                DriverInitInfoPtr;
  283.  
  284. typedef DriverInitInfo                     DriverReplaceInfo;
  285. typedef DriverInitInfo *                DriverReplaceInfoPtr;
  286.  
  287. struct DriverFinalInfo {
  288.     DriverRefNum                     refNum;
  289.     RegEntryID                         deviceEntry;
  290. };
  291. typedef struct DriverFinalInfo            DriverFinalInfo;
  292. typedef DriverFinalInfo *                DriverFinalInfoPtr;
  293.  
  294. typedef DriverFinalInfo                 DriverSupersededInfo;
  295. typedef DriverFinalInfo *                DriverSupersededInfoPtr;
  296.  
  297. /* Contents are command specific*/
  298.  
  299.  
  300. union IOCommandContents {
  301.     ParmBlkPtr                         pb;
  302.     DriverInitInfoPtr                 initialInfo;
  303.     DriverFinalInfoPtr                 finalInfo;
  304.     DriverReplaceInfoPtr             replaceInfo;
  305.     DriverSupersededInfoPtr         supersededInfo;
  306. };
  307. typedef union IOCommandContents            IOCommandContents;
  308. typedef CALLBACK_API_C( OSErr , DriverEntryPointPtr )(AddressSpaceID SpaceID, IOCommandID CommandID, IOCommandContents Contents, IOCommandCode Code, IOCommandKind Kind);
  309. /* Record to describe a file-based driver candidate */
  310.  
  311. struct FileBasedDriverRecord {
  312.     FSSpec                             theSpec;                    /* file specification*/
  313.     MacDriverType                     theType;                    /* nameInfoStr + version number*/
  314.     Boolean                         compatibleProp;                /* true if matched using a compatible name*/
  315.     UInt8                             pad[3];                        /* alignment*/
  316. };
  317. typedef struct FileBasedDriverRecord    FileBasedDriverRecord;
  318. typedef FileBasedDriverRecord *            FileBasedDriverRecordPtr;
  319. /* Detailed Record to describe a file-based driver candidate. Includes fragment name */
  320.  
  321. struct FileBasedDriverDetailed {
  322.     FileBasedDriverRecord             fileBasedDriver;
  323.     Str63                             fragName;
  324. };
  325. typedef struct FileBasedDriverDetailed    FileBasedDriverDetailed;
  326. typedef FileBasedDriverDetailed *        FileBasedDriverDetailedPtr;
  327. /* Driver Loader API */
  328. #define DECLARE_DRIVERDESCRIPTION(N_ADDITIONAL_SERVICES)\
  329.         struct {\
  330.             DriverDescription    fixed;\
  331.             DriverServiceInfo    additional_service[N_ADDITIONAL_SERVICES-1];\
  332.         };
  333.  
  334.  
  335. EXTERN_API_C( SInt16 )
  336. HigherDriverVersion                (const NumVersion *        driverVersion1,
  337.                                  const NumVersion *        driverVersion2);
  338.  
  339. EXTERN_API_C( OSErr )
  340. VerifyFragmentAsDriver            (CFragConnectionID         fragmentConnID,
  341.                                  DriverEntryPointPtr *    fragmentMain,
  342.                                  DriverDescriptionPtr *    driverDesc);
  343.  
  344. EXTERN_API_C( OSErr )
  345. GetDriverMemoryFragment            (Ptr                     memAddr,
  346.                                  long                     length,
  347.                                  ConstStr63Param         fragName,
  348.                                  CFragConnectionID *    fragmentConnID,
  349.                                  DriverEntryPointPtr *    fragmentMain,
  350.                                  DriverDescriptionPtr *    driverDesc);
  351.  
  352. EXTERN_API_C( OSErr )
  353. GetDriverDiskFragment            (FSSpecPtr                 fragmentSpec,
  354.                                  CFragConnectionID *    fragmentConnID,
  355.                                  DriverEntryPointPtr *    fragmentMain,
  356.                                  DriverDescriptionPtr *    driverDesc);
  357.  
  358. EXTERN_API_C( OSErr )
  359. GetNamedDriverDiskFragment        (FSSpecPtr                 fragmentSpec,
  360.                                  ConstStr63Param         fragName,
  361.                                  CFragConnectionID *    fragmentConnID,
  362.                                  DriverEntryPointPtr *    fragmentMain,
  363.                                  DriverDescriptionPtr *    driverDesc);
  364.  
  365. EXTERN_API_C( OSErr )
  366. InstallDriverFromFragment        (CFragConnectionID         fragmentConnID,
  367.                                  RegEntryID *            device,
  368.                                  UnitNumber             beginningUnit,
  369.                                  UnitNumber             endingUnit,
  370.                                  DriverRefNum *            refNum);
  371.  
  372. EXTERN_API_C( OSErr )
  373. InstallDriverFromFile            (FSSpecPtr                 fragmentSpec,
  374.                                  RegEntryID *            device,
  375.                                  UnitNumber             beginningUnit,
  376.                                  UnitNumber             endingUnit,
  377.                                  DriverRefNum *            refNum);
  378.  
  379. EXTERN_API_C( OSErr )
  380. InstallDriverFromMemory            (Ptr                     memory,
  381.                                  long                     length,
  382.                                  ConstStr63Param         fragName,
  383.                                  RegEntryID *            device,
  384.                                  UnitNumber             beginningUnit,
  385.                                  UnitNumber             endingUnit,
  386.                                  DriverRefNum *            refNum);
  387.  
  388. EXTERN_API_C( OSErr )
  389. InstallDriverFromResource        (SInt16                 theRsrcID,
  390.                                  ConstStr255Param         theRsrcName,
  391.                                  RegEntryIDPtr             theDevice,
  392.                                  UnitNumber             theBeginningUnit,
  393.                                  UnitNumber             theEndingUnit,
  394.                                  DriverRefNum *            theRefNum);
  395.  
  396. EXTERN_API_C( OSErr )
  397. InstallDriverFromDisk            (Ptr                     theDriverName,
  398.                                  RegEntryID *            theDevice,
  399.                                  UnitNumber             theBeginningUnit,
  400.                                  UnitNumber             theEndingUnit,
  401.                                  DriverRefNum *            theRefNum);
  402.  
  403. EXTERN_API_C( OSErr )
  404. FindDriversForDevice            (RegEntryID *            device,
  405.                                  FSSpec *                fragmentSpec,
  406.                                  DriverDescription *    fileDriverDesc,
  407.                                  Ptr *                    memAddr,
  408.                                  long *                    length,
  409.                                  StringPtr                 fragName,
  410.                                  DriverDescription *    memDriverDesc);
  411.  
  412. EXTERN_API_C( OSErr )
  413. FindDriverForDeviceFromFile        (RegEntryID *            device,
  414.                                  FSSpec *                fragmentSpec,
  415.                                  DriverDescription *    driverDesc,
  416.                                  StringPtr                 fragName);
  417.  
  418. EXTERN_API_C( OSErr )
  419. FindDriverCandidates            (RegEntryID *            deviceID,
  420.                                  Ptr *                    propBasedDriver,
  421.                                  RegPropertyValueSize *    propBasedDriverSize,
  422.                                  StringPtr                 deviceName,
  423.                                  MacDriverType *        propBasedDriverType,
  424.                                  Boolean *                gotPropBasedDriver,
  425.                                  FileBasedDriverRecordPtr  fileBasedDrivers,
  426.                                  ItemCount *            nFileBasedDrivers);
  427.  
  428. EXTERN_API_C( OSErr )
  429. FindDriverCandidatesDetailed    (RegEntryIDPtr             deviceID,
  430.                                  Ptr *                    propBasedDriver,
  431.                                  RegPropertyValueSize *    propBasedDriverSize,
  432.                                  StringPtr                 deviceName,
  433.                                  MacDriverType *        propBasedDriverType,
  434.                                  Boolean *                gotPropBasedDriver,
  435.                                  FileBasedDriverDetailedPtr  fileBasedDrivers,
  436.                                  ItemCount *            nFileBasedDrivers);
  437.  
  438. EXTERN_API_C( OSErr )
  439. ScanDriverCandidates            (RegEntryID *            deviceID,
  440.                                  FileBasedDriverRecordPtr  fileBasedDrivers,
  441.                                  ItemCount                 nFileBasedDrivers,
  442.                                  FileBasedDriverRecordPtr  matchingDrivers,
  443.                                  ItemCount *            nMatchingDrivers);
  444.  
  445. EXTERN_API_C( OSErr )
  446. ScanDriverCandidatesDetailed    (RegEntryID *            deviceID,
  447.                                  FileBasedDriverDetailedPtr  fileBasedDrivers,
  448.                                  ItemCount                 nFileBasedDrivers,
  449.                                  FileBasedDriverDetailedPtr  matchingDrivers,
  450.                                  ItemCount *            nMatchingDrivers);
  451.  
  452. EXTERN_API_C( SInt16 )
  453. CompareFileCandToPropCand        (RegEntryID *            device,
  454.                                  StringPtr                 deviceName,
  455.                                  DriverTypePtr             propBasedCandidate,
  456.                                  FileBasedDriverRecordPtr  fileBasedCandidate);
  457.  
  458. EXTERN_API_C( void )
  459. GetCompatibleProperty            (RegEntryID *            device,
  460.                                  StringPtr *            compatibleNames,
  461.                                  ItemCount *            nCompatibleNames);
  462.  
  463. EXTERN_API_C( Boolean )
  464. CompatibleDriverNames            (StringPtr                 nameInfoStr,
  465.                                  StringPtr                 compatibleNames,
  466.                                  ItemCount                 nCompatibleNames,
  467.                                  long *                    nameCount);
  468.  
  469. EXTERN_API_C( OSErr )
  470. GetDriverForDevice                (RegEntryID *            device,
  471.                                  CFragConnectionID *    fragmentConnID,
  472.                                  DriverEntryPointPtr *    fragmentMain,
  473.                                  DriverDescriptionPtr *    driverDesc);
  474.  
  475. EXTERN_API_C( OSErr )
  476. InstallDriverForDevice            (RegEntryID *            device,
  477.                                  UnitNumber             beginningUnit,
  478.                                  UnitNumber             endingUnit,
  479.                                  DriverRefNum *            refNum);
  480.  
  481. EXTERN_API_C( OSErr )
  482. GetDriverInformation            (DriverRefNum             refNum,
  483.                                  UnitNumber *            unitNum,
  484.                                  DriverFlags *            flags,
  485.                                  DriverOpenCount *        count,
  486.                                  StringPtr                 name,
  487.                                  RegEntryID *            device,
  488.                                  CFragSystem7Locator *    driverLoadLocation,
  489.                                  CFragConnectionID *    fragmentConnID,
  490.                                  DriverEntryPointPtr *    fragmentMain,
  491.                                  DriverDescription *    driverDesc);
  492.  
  493. EXTERN_API_C( OSErr )
  494. GetDriverDescription            (LogicalAddress         fragmentPtr,
  495.                                  DriverDescriptionPtr *    theDriverDesc);
  496.  
  497. EXTERN_API_C( OSStatus )
  498. GetNamedDriverDescFromFSSpec    (FSSpecPtr                 fragmentSpec,
  499.                                  StringPtr                 fragName,
  500.                                  DriverDescriptionPtr *    driverDesc);
  501.  
  502. EXTERN_API_C( OSErr )
  503. SetDriverClosureMemory            (CFragConnectionID         fragmentConnID,
  504.                                  Boolean                 holdDriverMemory);
  505.  
  506. EXTERN_API_C( OSErr )
  507. ReplaceDriverWithFragment        (DriverRefNum             theRefNum,
  508.                                  CFragConnectionID         fragmentConnID);
  509.  
  510. EXTERN_API_C( OSErr )
  511. OpenInstalledDriver                (DriverRefNum             refNum,
  512.                                  SInt8                     ioPermission);
  513.  
  514. EXTERN_API_C( OSErr )
  515. RenameDriver                    (DriverRefNum             refNum,
  516.                                  StringPtr                 newDriverName);
  517.  
  518. EXTERN_API_C( OSErr )
  519. RemoveDriver                    (DriverRefNum             refNum,
  520.                                  Boolean                 immediate);
  521.  
  522. EXTERN_API_C( OSErr )
  523. LookupDrivers                    (UnitNumber             beginningUnit,
  524.                                  UnitNumber             endingUnit,
  525.                                  Boolean                 emptyUnits,
  526.                                  ItemCount *            returnedRefNums,
  527.                                  DriverRefNum *            refNums);
  528.  
  529. EXTERN_API_C( UnitNumber )
  530. HighestUnitNumber                (void);
  531.  
  532. EXTERN_API_C( OSErr )
  533. DriverGestaltOn                    (DriverRefNum             refNum);
  534.  
  535. EXTERN_API_C( OSErr )
  536. DriverGestaltOff                (DriverRefNum             refNum);
  537.  
  538. EXTERN_API_C( Boolean )
  539. DriverGestaltIsOn                (DriverFlags             flags);
  540.  
  541.  
  542.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  543.                                                                                             #pragma parameter __D0 PBOpenSync(__A0)
  544.                                                                                             #endif
  545. EXTERN_API( OSErr )
  546. PBOpenSync                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA000);
  547.  
  548.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  549.                                                                                             #pragma parameter __D0 PBOpenAsync(__A0)
  550.                                                                                             #endif
  551. EXTERN_API( OSErr )
  552. PBOpenAsync                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA400);
  553.  
  554.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  555.                                                                                             #pragma parameter __D0 PBOpenImmed(__A0)
  556.                                                                                             #endif
  557. EXTERN_API( OSErr )
  558. PBOpenImmed                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA200);
  559.  
  560.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  561.                                                                                             #pragma parameter __D0 PBCloseSync(__A0)
  562.                                                                                             #endif
  563. EXTERN_API( OSErr )
  564. PBCloseSync                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA001);
  565.  
  566.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  567.                                                                                             #pragma parameter __D0 PBCloseAsync(__A0)
  568.                                                                                             #endif
  569. EXTERN_API( OSErr )
  570. PBCloseAsync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA401);
  571.  
  572.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  573.                                                                                             #pragma parameter __D0 PBCloseImmed(__A0)
  574.                                                                                             #endif
  575. EXTERN_API( OSErr )
  576. PBCloseImmed                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA201);
  577.  
  578.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  579.                                                                                             #pragma parameter __D0 PBReadSync(__A0)
  580.                                                                                             #endif
  581. EXTERN_API( OSErr )
  582. PBReadSync                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA002);
  583.  
  584.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  585.                                                                                             #pragma parameter __D0 PBReadAsync(__A0)
  586.                                                                                             #endif
  587. EXTERN_API( OSErr )
  588. PBReadAsync                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA402);
  589.  
  590.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  591.                                                                                             #pragma parameter __D0 PBReadImmed(__A0)
  592.                                                                                             #endif
  593. EXTERN_API( OSErr )
  594. PBReadImmed                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA202);
  595.  
  596.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  597.                                                                                             #pragma parameter __D0 PBWriteSync(__A0)
  598.                                                                                             #endif
  599. EXTERN_API( OSErr )
  600. PBWriteSync                        (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA003);
  601.  
  602.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  603.                                                                                             #pragma parameter __D0 PBWriteAsync(__A0)
  604.                                                                                             #endif
  605. EXTERN_API( OSErr )
  606. PBWriteAsync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA403);
  607.  
  608.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  609.                                                                                             #pragma parameter __D0 PBWriteImmed(__A0)
  610.                                                                                             #endif
  611. EXTERN_API( OSErr )
  612. PBWriteImmed                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA203);
  613.  
  614. /*
  615.     PBWaitIOComplete is a friendly way for applications to monitor
  616.     a pending asynchronous I/O operation in power-managed and
  617.     preemptive multitasking systems.
  618.  */
  619. EXTERN_API( OSErr )
  620. PBWaitIOComplete                (ParmBlkPtr             paramBlock,
  621.                                  Duration                 timeout);
  622.  
  623.  
  624. EXTERN_API( void )
  625. AddDrive                        (short                     drvrRefNum,
  626.                                  short                     drvNum,
  627.                                  DrvQElPtr                 qEl);
  628.  
  629. EXTERN_API( QHdrPtr )
  630. GetDrvQHdr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x0308);
  631.  
  632.  
  633.  
  634. EXTERN_API( DCtlHandle )
  635. GetDCtlEntry                    (short                     refNum);
  636.  
  637. /*
  638.     SetChooserAlert used to simply set a bit in a low-mem global
  639.     to tell the Chooser not to display its warning message when
  640.     the printer is changed. However, under MultiFinder and System 7,
  641.     this low-mem is swapped out when a layer change occurs, and the
  642.     Chooser never sees the change. It is obsolete, and completely
  643.     unsupported on the PowerPC. 68K apps can still call it if they
  644.     wish.
  645.     
  646.     pascal Boolean SetChooserAlert(Boolean f);
  647.  
  648. */
  649.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  650.                                                                                             #pragma parameter __D0 DriverInstall(__A0, __D0)
  651.                                                                                             #endif
  652. EXTERN_API( OSErr )
  653. DriverInstall                    (DRVRHeaderPtr             drvrPtr,
  654.                                  short                     refNum)                                ONEWORDINLINE(0xA03D);
  655.  
  656.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  657.                                                                                             #pragma parameter __D0 DriverInstallReserveMem(__A0, __D0)
  658.                                                                                             #endif
  659. EXTERN_API( OSErr )
  660. DriverInstallReserveMem            (DRVRHeaderPtr             drvrPtr,
  661.                                  short                     refNum)                                ONEWORDINLINE(0xA43D);
  662.  
  663. /*
  664.   Note: DrvrInstall() is no longer supported, becuase it never really worked anyways.
  665.           There will soon be a DriverInstall() which does the right thing.
  666.  
  667.         DrvrRemove has been renamed to DriverRemove.  But, InterfaceLib for PowerPC
  668.         still exports DrvrRemove, so a macro is used to map the new name to old.
  669.  
  670. */
  671.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  672.                                                                                             #pragma parameter __D0 DrvrRemove(__D0)
  673.                                                                                             #endif
  674. EXTERN_API( OSErr )
  675. DrvrRemove                        (short                     refNum)                                ONEWORDINLINE(0xA03E);
  676.  
  677. #define DriverRemove(refNum) DrvrRemove(refNum)
  678.  
  679. /*
  680.     Shim mechnanism only exist in Maxwell world.  A Shim is a translation layer
  681.     and looks like a DRVR. 
  682. */
  683. typedef CALLBACK_API( OSStatus , ShimEntryPoint )(Ptr paramBlock, Ptr refcon);
  684. EXTERN_API( OSStatus )
  685. DriverInstallShim                (DRVRHeaderPtr             drvrPtr,
  686.                                  ShimEntryPoint         shim,
  687.                                  short                     refNum,
  688.                                  void *                    refcon);
  689.  
  690. EXTERN_API( OSStatus )
  691. DriverRemoveShim                (short                     refNum);
  692.  
  693. EXTERN_API( OSStatus )
  694. DriverReturnShimRefcon            (short                     refNum,
  695.                                  void **                refcon);
  696.  
  697. EXTERN_API_C( OSErr )
  698. IOShimCommandIsComplete            (ParmBlkPtr             thePB,
  699.                                  OSErr                     result);
  700.  
  701. #if TARGET_OS_MAC
  702.     #define MacOpenDriver OpenDriver
  703. #endif
  704. EXTERN_API( OSErr )
  705. MacOpenDriver                    (ConstStr255Param         name,
  706.                                  short *                drvrRefNum);
  707.  
  708. #if TARGET_OS_MAC
  709.     #define MacCloseDriver CloseDriver
  710. #endif
  711. EXTERN_API( OSErr )
  712. MacCloseDriver                    (short                     refNum);
  713.  
  714. EXTERN_API( OSErr )
  715. Control                            (short                     refNum,
  716.                                  short                     csCode,
  717.                                  const void *            csParamPtr);
  718.  
  719. EXTERN_API( OSErr )
  720. Status                            (short                     refNum,
  721.                                  short                     csCode,
  722.                                  void *                    csParamPtr);
  723.  
  724. EXTERN_API( OSErr )
  725. KillIO                            (short                     refNum);
  726.  
  727.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  728.                                                                                             #pragma parameter __D0 Fetch(__A1)
  729.                                                                                             #endif
  730. EXTERN_API( long )
  731. Fetch                            (DCtlPtr                 dce)                                THREEWORDINLINE(0x2078, 0x08F4, 0x4E90);
  732.  
  733.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  734.                                                                                             #pragma parameter __D0 Stash(__A1, __D0)
  735.                                                                                             #endif
  736. EXTERN_API( long )
  737. Stash                            (DCtlPtr                 dce,
  738.                                  char                     data)                                THREEWORDINLINE(0x2078, 0x08F8, 0x4E90);
  739.  
  740.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  741.                                                                                             #pragma parameter IODone(__A1, __D0)
  742.                                                                                             #endif
  743. EXTERN_API( void )
  744. IODone                            (DCtlPtr                 dce,
  745.                                  OSErr                     ioResult)                            THREEWORDINLINE(0x2078, 0x08FC, 0x4E90);
  746.  
  747.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  748.                                                                                             #pragma parameter __D0 PBControlSync(__A0)
  749.                                                                                             #endif
  750. EXTERN_API( OSErr )
  751. PBControlSync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA004);
  752.  
  753.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  754.                                                                                             #pragma parameter __D0 PBControlAsync(__A0)
  755.                                                                                             #endif
  756. EXTERN_API( OSErr )
  757. PBControlAsync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA404);
  758.  
  759.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  760.                                                                                             #pragma parameter __D0 PBControlImmed(__A0)
  761.                                                                                             #endif
  762. EXTERN_API( OSErr )
  763. PBControlImmed                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA204);
  764.  
  765.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  766.                                                                                             #pragma parameter __D0 PBStatusSync(__A0)
  767.                                                                                             #endif
  768. EXTERN_API( OSErr )
  769. PBStatusSync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA005);
  770.  
  771.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  772.                                                                                             #pragma parameter __D0 PBStatusAsync(__A0)
  773.                                                                                             #endif
  774. EXTERN_API( OSErr )
  775. PBStatusAsync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA405);
  776.  
  777.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  778.                                                                                             #pragma parameter __D0 PBStatusImmed(__A0)
  779.                                                                                             #endif
  780. EXTERN_API( OSErr )
  781. PBStatusImmed                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA205);
  782.  
  783.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  784.                                                                                             #pragma parameter __D0 PBKillIOSync(__A0)
  785.                                                                                             #endif
  786. EXTERN_API( OSErr )
  787. PBKillIOSync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA006);
  788.  
  789.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  790.                                                                                             #pragma parameter __D0 PBKillIOAsync(__A0)
  791.                                                                                             #endif
  792. EXTERN_API( OSErr )
  793. PBKillIOAsync                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA406);
  794.  
  795.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  796.                                                                                             #pragma parameter __D0 PBKillIOImmed(__A0)
  797.                                                                                             #endif
  798. EXTERN_API( OSErr )
  799. PBKillIOImmed                    (ParmBlkPtr             paramBlock)                            ONEWORDINLINE(0xA206);
  800.  
  801. EXTERN_API( short )
  802. OpenDeskAcc                        (ConstStr255Param         deskAccName)                        ONEWORDINLINE(0xA9B6);
  803.  
  804. EXTERN_API( void )
  805. CloseDeskAcc                    (short                     refNum)                                ONEWORDINLINE(0xA9B7);
  806.  
  807. EXTERN_API_C( short )
  808. opendeskacc                        (const char *            deskAccName);
  809.  
  810. EXTERN_API_C( OSErr )
  811. opendriver                        (const char *            driverName,
  812.                                  short *                refNum);
  813.  
  814. /*
  815.     The PBxxx() routines are obsolete.  
  816.     
  817.     Use the PBxxxSync(), PBxxxAsync(), or PBxxxImmed version instead.
  818. */
  819. #define PBControl(pb, async) ((async) ? PBControlAsync(pb) : PBControlSync(pb))
  820. #define PBStatus(pb, async) ((async) ? PBStatusAsync(pb) : PBStatusSync(pb))
  821. #define PBKillIO(pb, async) ((async) ? PBKillIOAsync(pb) : PBKillIOSync(pb))
  822.  
  823. #define PBOpen(pb, async) ((async) ? PBOpenAsync(pb) : PBOpenSync(pb))
  824. #define PBClose(pb, async) ((async) ? PBCloseAsync(pb) : PBCloseSync(pb))
  825. #define PBRead(pb, async) ((async) ? PBReadAsync(pb) : PBReadSync(pb))
  826. #define PBWrite(pb, async) ((async) ? PBWriteAsync(pb) : PBWriteSync(pb))
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833. #if PRAGMA_STRUCT_ALIGN
  834.     #pragma options align=reset
  835. #elif PRAGMA_STRUCT_PACKPUSH
  836.     #pragma pack(pop)
  837. #elif PRAGMA_STRUCT_PACK
  838.     #pragma pack()
  839. #endif
  840.  
  841. #ifdef PRAGMA_IMPORT_OFF
  842. #pragma import off
  843. #elif PRAGMA_IMPORT
  844. #pragma import reset
  845. #endif
  846.  
  847. #ifdef __cplusplus
  848. }
  849. #endif
  850.  
  851. #endif /* __DEVICES__ */
  852.  
  853.